<template>
  <StyleProvider hashPriority="low" :transformers="[legacyLogicalPropertiesTransformer]">
    <ConfigProvider :locale="getAntdLocale">
      <AppProvider>
        <RouterView />
      </AppProvider>
    </ConfigProvider>
  </StyleProvider>
</template>

<script lang="ts" setup>
import { onMounted, CSSProperties, ref, onUnmounted } from 'vue'
import {
  StyleProvider,
  legacyLogicalPropertiesTransformer,
  ConfigProvider
} from 'ant-design-vue';
import { AppProvider } from '/@/components/Application';
import { useLocale } from '/@/locales/useLocale';
import { isLoginPage, PageEnum } from '/@/enums/pageEnum';
import * as authCache from '/@/utils/cache/module';

// 解决日期时间国际化问题
import 'dayjs/locale/zh-cn';
const { getAntdLocale } = useLocale();
onMounted(() => {
  const tenantName = authCache.getSelectTenant()?.name
  if (tenantName) {
    window.document.title = window.document.title + '-' + tenantName
  }
  
  document.addEventListener('visibilitychange', handleVisibilitychange, true);
})

onUnmounted(() => {
  document.removeEventListener('visibilitychange', handleVisibilitychange, true);
})

const handleVisibilitychange = () => {
  const isHidden = document.hidden;
  if (isHidden) {
    // 页面切入,
    if (isLoginPage()) {
      return
    }
    
  } else {
    // 页面切出,浏览器不处于当前页面
  }
}

</script>

<style lang="less">
  body {
    // line-height: 1.5715;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
      'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
      'Noto Color Emoji';
    overflow: auto;
    overflow-y: auto !important;
  }
</style>